using System;
using LS.Saving;
using Unity.VisualScripting;

namespace LS.VisualScripting
{
    [UnitShortTitle("Save Database")]
    [UnitSurtitle("Failure")]
    public sealed class SaveDatabaseFailure : GFEventUnit<SaveDatabaseFailureEventArgs>
    {
        protected override int EventId => LoadDatabaseFailureEventArgs.EventId;
        protected override string HookName => nameof(SaveDatabaseFailure);

        [DoNotSerialize]
        public ValueOutput GroupName { get; set; }
        
        [DoNotSerialize]
        public ValueOutput File { get; set; }
        
        [DoNotSerialize]
        public ValueOutput Database { get; set; }
        
        [DoNotSerialize]
        public ValueOutput Error { get; set; }
        
        protected override void Definition()
        {
            base.Definition();
            GroupName = ValueOutput<string>(nameof(GroupName));
            File = ValueOutput<IDataFile>(nameof(File));
            Database = ValueOutput<Database>(nameof(Database));
            Error = ValueOutput<string>(nameof(Error));
        }

        protected override void AssignArguments(Flow flow, SaveDatabaseFailureEventArgs args)
        {
            base.AssignArguments(flow, args);
            flow.SetValue(GroupName, args.GroupName);
            flow.SetValue(File, args.File);
            flow.SetValue(Database, args.Database);
            flow.SetValue(Error, args.Error);
        }
    }
}